home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: undoInsertSmallObj.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:03 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "pool.h"
- #include "log.h"
- #include "volume.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "logaction.h"
- #include "openlog.h"
- #include "undo.h"
- #include "undo_extfuncs.h"
- #include "bf_extfuncs.h"
- #include "log_extfuncs.h"
- #include "log_intfuncs.h"
- #include "sm_extfuncs.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "sm_macro.h"
- #ifdef INIT_LRC_IS_LSN
- # include "log_globals.h"
- #endif
-
-
- void
- undoInsertSmallObj (
-
- LOGRECORDHDR *recordHeader
- )
- {
-
- GROUPLINK *groupLink;
- SLOTTEDPAGE *slottedPage;
- PID *pid;
- WRITEINFO *opInfo; /* info on logged operation */
- FULLWRITEINFO *fullOpInfo; /* info on no data operation */
- char *data; /* data inserted */
- int dataSize;
- OID oid;
- LOGRECORDINFO recordInfo;
- #ifdef INIT_LRC_IS_LSN
- LRC tempLRC;
- LRC *lrc = &tempLRC;
- #else
- LRC *lrc;
- #endif /* INIT_LRC_IS_LSN; */
- LSN lsn;
- FORCEMARK forceMark;
- BOOL actionDone; /* Indicates whether the action
- was ever performed on the page */
- INIT_MISSING_UPDATE_INFO( Active->transRec );
-
-
- TRPRINT(TR_IO, TR_LEVEL_1, ("lsn:%d", recordHeader->recordLSN));
-
- /* get a pointer to the page for the record */
- pid = &(recordHeader->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- if (recordHeader->action == LOG_ACTION_INSERT_SMALL_OBJ) {
- /* get pointer to destroy info */
- opInfo = (WRITEINFO*) GET_LOG_IMAGE(recordHeader, 0);
-
- /* get pointer to header, data */
- data = GET_LOG_IMAGE(recordHeader, 1);
- dataSize = GET_LOG_IMAGE_SIZE(recordHeader, 1);
- } else {
- SM_ASSERT(LEVEL_3, recordHeader->action == LOG_ACTION_INSERT_SMALL_OBJ_ND);
- fullOpInfo = (FULLWRITEINFO*) GET_LOG_IMAGE(recordHeader, 0);
- opInfo = &(fullOpInfo->common);
- dataSize = fullOpInfo->size;
- data = NULL;
- }
-
- /* read in the page */
- if ((groupLink = bf_ReadPage(UserBufGroup, pid, SLOTTED_PAGE2SIZE, BF_SEM)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
- groupLink->pageHash->pageType = PAGE_SLOTTED;
-
- /* get a pointer to the slotted page */
- slottedPage = (SLOTTEDPAGE *) groupLink->bufFrame;
- if (CHECK_SLOTTED_MAGIC(slottedPage)) {
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /* See if the action was actually done */
- actionDone = compareLRC(&(recordHeader->actionLRC), &(slottedPage->header.lrc) ) <= 0;
-
- /*
- * it is possible that the action
- * never made it to the page on the server, so missing update
- * information may need to be recordedjj
- *
- * Process any missing updates, and return a pointer to
- * the lrc to increment. This will either be the lrc on the
- * slotted page, or the lrc in the missingUpdatePageTable
- */
- RECORD_MISSING_UPDATE( actionDone, &lrc, missingUpdateInfo, pid,
- &(slottedPage->header.lrc),
- groupLink->pageHash, recordHeader, PAGE_SLOTTED);
-
- /* increment the lrc on the page */
- GENERATE_LRC(lrc);
-
- /*
- * Log the undo insertion
- */
- if (recordHeader->action == LOG_ACTION_INSERT_SMALL_OBJ) {
- recordInfo.action = LOG_ACTION_DELETE_SMALL_OBJ;
- recordInfo.imageCount = 2;
- recordInfo.imageSize[0] = sizeof(*opInfo);
- recordInfo.imageData[0] = (VOID *) opInfo;
- recordInfo.imageSize[1] = GET_LOG_IMAGE_SIZE(recordHeader, 1);
- recordInfo.imageData[1] = (VOID *)data;
- } else {
- recordInfo.action = LOG_ACTION_DELETE_SMALL_OBJ_ND;
- recordInfo.imageCount = 1;
- recordInfo.imageSize[0] = sizeof(*fullOpInfo);
- recordInfo.imageData[0] = (VOID *) fullOpInfo;
- }
- recordInfo.type = LOG_REC_TYPE_COMPENSATION;
- recordInfo.actionPid = pid;
- recordInfo.actionLRC = lrc;
- recordInfo.nextUndoLSN = recordHeader->previousLSN;
- recordInfo.flags = NOFLAGS;
-
- /* write the record to the log */
- if ((forceMark = writeLogRecord((TRANSREC *) Active->transRec, &recordInfo,
- &lsn, NOFLAGS)) < 0) {
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /* mark the page dependency */
- #ifndef INIT_LRC_IS_LSN
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
- #endif
-
- /*
- * perform the undo by deleting from the object, assuming
- * the actio was done
- */
- if (actionDone) {
- #ifdef INIT_LRC_IS_LSN
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
- #endif
-
- oid.diskAddr.unique = opInfo->unique;
- oid.diskAddr.slot = opInfo->slot;
- oid.diskAddr.page = pid->page;
- oid.diskAddr.volid = pid->volid;
- if (sm_DeleteFromSmallObj(slottedPage, &oid, opInfo->start, dataSize)) {
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
- }
-
- /*
- * release the semaphore and unfix the page, dirty the page if the
- * action was done
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
- bf_UnfixPage(groupLink, BF_DEFAULT, actionDone);
-
- /* return success */
- return;
- }
-